//
//  CellForShoot.m
//  MY Project For Sport
//
//  Created by dllo on 16/2/27.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "CellForShoot.h"
#import <DKNightVersion.h>
#import "ModelForShoot.h"
#import <SDWebImage/UIImageView+WebCache.h>

#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height

#define WEIGHTT [UIScreen mainScreen].bounds.size.width / 375
#define HEIGHTT [UIScreen mainScreen].bounds.size.height / 667


@interface CellForShoot ()

@property (nonatomic, retain) UILabel *labelForNum;
@property (nonatomic, retain) UIImageView *heardView;
@property (nonatomic, retain) UILabel *labelForTeam;
@property (nonatomic, retain) UILabel *labelForCount;
@property (nonatomic, retain) UILabel *labelForName;
@end

@implementation CellForShoot

- (void)dealloc {
    [_labelForNum release];
    [_heardView release];
    [_labelForTeam release];
    [_labelForCount release];
    [_labelForName release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        
        self.contentView.dk_backgroundColorPicker = DKColorWithRGB(0xffffff, 0x343434);

        [self createSubView];
        
    }

    return self;

}

- (void)createSubView {

    self.labelForNum = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForNum];
    [_labelForNum release];
    
    self.labelForTeam = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForTeam];
    [_labelForTeam release];
    
    self.labelForCount = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForCount];
    [_labelForCount release];
    
    self.heardView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.heardView];
    [_heardView release];
    
    self.labelForName = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForName];
    [_labelForName release];
    
    
}

- (void)layoutSubviews {

    [super layoutSubviews];
    
    self.labelForNum.frame = CGRectMake(20 * WEIGHTT, WIDTH / 28, WIDTH / 15, WIDTH / 15);

    self.labelForNum.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    
    
    self.heardView.frame = CGRectMake(10 * WEIGHTT + WIDTH / 15 + WIDTH / 15 + WIDTH / 10, 5 * HEIGHTT, WIDTH / 11, WIDTH / 11);
    self.heardView.layer.cornerRadius = WIDTH / 22;
    self.heardView.layer.masksToBounds = YES;
    
    
    self.labelForName.frame = CGRectMake(WIDTH / 15 + WIDTH / 15 + WIDTH / 10, WIDTH / 11 + 7 * HEIGHTT, WIDTH / 8 + 5 * WEIGHTT, WIDTH / 35) ;
    
    
    self.labelForTeam.frame = CGRectMake(WIDTH / 2, WIDTH / 28, WIDTH / 5, WIDTH / 15);
    
    
    self.labelForCount.frame = CGRectMake(30 * WEIGHTT + WIDTH / 20 + WIDTH / 15 + WIDTH / 4 + WIDTH / 13 * 5, WIDTH / 28, WIDTH / 6, WIDTH / 15);
    
    
}


- (void)passModelForShoot:(ModelForShoot *)model {

    self.labelForNum.text = model.num;

    [self.heardView sd_setImageWithURL:[NSURL URLWithString:model.pic]];
    
    self.labelForName.text = model.player_name;
    self.labelForName.font = [UIFont systemFontOfSize:12];
    self.labelForName.textAlignment = NSTextAlignmentCenter;
    
    self.labelForTeam.text = model.team_name;
    
    self.labelForCount.text = model.item1;
 
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
